package edu.java.homework.hw03.ipj05;

public class J04 {

    /**
     * @param args
     */
    public static void main(String[] args) {
//	int[] arr= { 1, 2, 3, 4, 5,10,23,16 };
	int[] arr= {12,14,10,7,5,3,2,1,0,-12,-19,0};
//	int[] arr=null;
//	int[] arr={1};
	System.out.println("DescendingOrderInTheArray? : " + isDiffElemsInArray(arr));

    }

    /**
     * Check if the elements in the array are different
     * 
     * @param array
     * @return boolean
     * @throws IllegalArgumentException
     *             array NOT null pointed
     */
    public static boolean isDiffElemsInArray(int[] array) {
	if (array == null) {
	    throw new IllegalArgumentException(
		    "The array is null pointed.Incorrect input.");
	}
	int length = array.length;
	if (length == 1) {
	    return true;
	}
	for (int i = 0; i <= length - 2; i++) {
	    for (int j = i + 1; j <= length - 1; j++) {
		if (array[i] == array[j]) {
		    return false;
		}
	    }
	}
	return true;
    }

}
